package instruction;
import structureDonnee.Expression;
import structureDonnee.Invariant;
import structureDonnee.Variable;


public class Instruction extends Affectation {
	//il y a trois types de Instruciton: Affectation, FaireRienInstruction, UpdateInstruction
	//On differencie des differents types par un champ int type;
	//Instrucion extends Affection et en meme temps
	//il a un champ Invariant update au cas ou qu'il est UpdateInstruction
	private static final int AffectationInstruction = 0;
	private static final int FaireRienInstruction = 1;
	private static final int UpdateInstruction = 2;
	
	int type;
	public Invariant update;
	
	public Instruction(){}
	public Instruction(Instruction instr){
		update = new Invariant(instr.update);
		if(instr.type==0) type = 0;
		if(instr.type==1) type = 1;
		if(instr.type==2) type = 2;
		this.expr = new Expression(instr.expr);
		this.v = new Variable(instr.v);
	}
	
	public Instruction(Affectation aff){
		type = AffectationInstruction;
		this.expr=new Expression(aff.getExpr().getListExpr());
		this.v=new Variable(aff.v.getNom());
	}
	public Instruction(UpdateInstruction fri){
		type = UpdateInstruction;
		update = new Invariant(fri.forUpdate.getListIne());
	}
	public Instruction(FaireRienInstruction fri){
		type = FaireRienInstruction;
	}
	public int getType(){
		return type;
	}
}
